<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        var regPos = /^[1-9]+[0-9]*]*$/;
        function f() {
            var a = document.getElementById('a').value;
            var b = document.getElementById('b').value;
            if (regPos.test(a)&&regPos.test(b)){
                document.getElementById('c').value = parseInt(a)+parseInt(b);
            } else {
                document.getElementById('c').value = "请输入整数";
            }
        }
    </script>
</head>
<body>
    <input id="a" type="text">
    +
    <input id="b" type="text">
    <button onclick="f()">=</button>
    <input id="c" type="text">
</body>
</html>